import { useEffect, useRef } from 'react';
import { App as Comments } from '../13-B站评论列表-持久化存储/App';

export const App = () => {
  // 定义 ref 变量容器
  const inputRef = useRef(null);
  const numRef = useRef(0);
  const commentRef = useRef(null);

  // useEffect 中设置光标
  useEffect(() => {
    // 设置输入框焦点
    inputRef.current.focus();
  }, []);

  return (
    <div>
      <Comments ref={commentRef} />
      <input type={'text'} placeholder={'请输入'} ref={inputRef} />
      <button
        onClick={(e) => {
          console.log(inputRef.current);
          console.log(inputRef.current.value);
          console.log(numRef.current);
          console.log(commentRef.current);
        }}
      >
        提交
      </button>
    </div>
  );
};
